package com.gec.zhs.controller;

import java.util.List;

import com.gec.zhs.entity.query.OrgQuery;
import com.gec.zhs.entity.po.Org;
import com.gec.zhs.entity.vo.ResponseVO;
import com.gec.zhs.service.OrgService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 组织表 Controller
 */
@RestController("orgController")
@RequestMapping("/org")
public class OrgController extends ABaseController{

	@Resource
	private OrgService orgService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(OrgQuery query){
		return getSuccessResponseVO(orgService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(Org bean) {
		orgService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<Org> listBean) {
		orgService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Org> listBean) {
		orgService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getOrgById")
	public ResponseVO getOrgById(String id) {
		return getSuccessResponseVO(orgService.getOrgById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateOrgById")
	public ResponseVO updateOrgById(Org bean,String id) {
		orgService.updateOrgById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteOrgById")
	public ResponseVO deleteOrgById(String id) {
		orgService.deleteOrgById(id);
		return getSuccessResponseVO(null);
	}
}